﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EzDesk.Utility.TimerService
{
    public class EverydayTimerTask : TimerTaskBase
    {
        protected EverydayTimerTask(string taskName, TimeSpan dayExecuteTime)
            : base(taskName)
        {
            this.DayExecuteTime = dayExecuteTime;
        }
        protected EverydayTimerTask(string taskName)
            : base(taskName)
        {
        }

       
        public TimeSpan DayExecuteTime
        {
            get;
            protected set;
        }

        private DateTime _executeTime = DateTime.MinValue;

        public sealed override DateTime ExecuteTime
        {
            get
            {
                if (_executeTime.Date != DateTime.Now.Date)
                    _executeTime = DateTime.Now.Date.Add(DayExecuteTime);
                return _executeTime;
            }
            protected set { _executeTime = value; }
        }
    }
}
